/**************************
* @Summary
* @Author 20009200303 赵传博
* @Date 6/15/2022
* @Note
*****************************/

#ifndef REVIEW_ARRAY_H
#define REVIEW_ARRAY_H
#include <iostream>
#include <string.h>

class IndexError{};

template<typename T>
class ARRAY{
private:
    size_t m_size;
    T *m_ptr;
public:
    ARRAY(size_t size) : m_size(size){
        m_ptr = new T[size];
        memset(m_ptr, 0, size * sizeof(T));
    }
    ~ARRAY(){
        delete [] m_ptr;
    }
    T& at(int index);
};

template<typename T>
T& ARRAY<T>::at(int index) {
    if(index < 0 || index >= m_size){
        throw IndexError();
    }
    return m_ptr[index];
}


#endif //REVIEW_ARRAY_H
